const Koa = require('koa');
const bodyParser = require('koa-bodyparser');
const koaStatic = require('koa-static')
const views = require('koa-views');

const app = new Koa();
const router = require('./router')
app.use(koaStatic('./public', {
  index: 'index.html'
}));

const render = views(__dirname + '/views', {
  // map: {
  //   ejs: 'ejs',
  // },
  extension: 'ejs'
})

// Must be used before any router is used
app.use(render)

app.use(bodyParser());
app
  .use(router.routes())
  .use(router.allowedMethods());

app.listen(3000);
